package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.StroeInoutFileDao;
import cn.topevery.garden.entity.po.StroeInoutFile;
import cn.topevery.garden.entity.query.StroeInoutFileQuery;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 *
 * @author code-generate
 * @date 2021-08-30
 */
@Service
public class StroeInoutFileLogic extends BaseLogic<StroeInoutFile> {
    @Autowired
    StroeInoutFileDao stroeInoutFileDao;

    @Override
    public BaseEntityDao<StroeInoutFile, Integer> getDao() {
        return stroeInoutFileDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<StroeInoutFile> listPage(StroeInoutFileQuery query) {
        return stroeInoutFileDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        stroeInoutFileDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param stroeInoutFiles 实体
     */
    public void saveOrUpdate(String userId,Integer pid, List<StroeInoutFile> stroeInoutFiles){
        stroeInoutFileDao.deleteById(pid);
        for (StroeInoutFile stroeInoutFile : stroeInoutFiles){
            stroeInoutFile.setMainId(pid);
            stroeInoutFileDao.saveOrUpdate(userId,stroeInoutFile);
        }
    }

    /**
     * 描述 获取列表.
     *
     * @param pid the pid
     * @return the list
     * @author wenzhao.lin
     * @created 2021 -08-30 10:11:08 Get list by pid list.
     */
    public List<StroeInoutFile> getListByPid(Integer pid){
        return stroeInoutFileDao.getListByPid(pid);
    }
}
